﻿@model WebDuLichDev.Models.LoginModel

@{
    ViewBag.Title = "Log in";
    Layout = "~/Views/Shared/_Layout.cshtml";
    
}
@Styles.Render("~/Content/style_login3d.css")


<section class="main">
    @using (Html.BeginForm("Login","Account", new { ReturnUrl = ViewBag.ReturnUrl },FormMethod.Post, new { @class = "form-2" }))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)
      
        if (!ViewData.ModelState.IsValid)
        { 
         <div id="messageBox" class="alert ">
            <a class="close" data-dismiss="alert">×</a>
             <p>@Html.ValidationMessage("LoginErr") </p>                  
        </div>
        }
        <h1 style="text-align:center"><span class="log-in">@Resources.Language.Login</span></h1>
        <p class="float">
            <label for="login"><i class="icon-user"></i>@Resources.Language.Username</label>
            @*<input type="text" name="LoginModel.UserName" placeholder="Username or email">*@
            @Html.TextBoxFor(m=>m.UserName,new {placeholder=@Resources.Language.Username})
        </p>
        <p class="float">
            <label for="password"><i class="icon-lock"></i>@Resources.Language.Password</label>
            @*<input type="password" name="Password" placeholder="Password" class="showpassword">*@
            @Html.PasswordFor(m=>m.Password,new { placeholder=@Resources.Language.Password, @class="showpassword"})
        </p>
        <p class="clearfix">
            <a href="@Url.Action("ExternalLoginsList", new { ReturnUrl = ViewBag.ReturnUrl })" class="log-twitter">@Resources.Language.LoginWithSocial</a>
            <input type="submit" name="submit" value="@Resources.Language.Login">
        </p>
    }    ​​
</section>

<script type="text/javascript">
    $(function () {
        $(".showpassword").each(function (index, input) {
            var $input = $(input);
            $("<p class='opt'/>").append(
                $("<input type='checkbox' class='showpasswordcheckbox' id='showPassword' />").click(function () {
                    var change = $(this).is(":checked") ? "text" : "password";
                    var rep = $("<input placeholder='@Resources.Language.Password' type='" + change + "' />")
                        .attr("id", $input.attr("id"))
                        .attr("name", $input.attr("name"))
                        .attr('class', $input.attr('class'))
                        .val($input.val())
                        .insertBefore($input);
                    $input.remove();
                    $input = rep;
                })
            ).append($("<label for='showPassword'/>").text('@Resources.Language.Showpassword')).insertAfter($input.parent());
        });

        $('#showPassword').click(function () {
            if ($("#showPassword").is(":checked")) {
                $('.icon-lock').addClass('icon-pencil');
                $('.icon-pencil').removeClass('icon-lock');
            } else {
                $('.icon-pencil').addClass('icon-lock');
                $('.icon-lock').removeClass('icon-pencil');
            }
        });
    });
</script>